import { defineStore } from "pinia";
import { store } from "@/store";
import { getStorage } from "@/utils/storage/storage";
// import type { appToken, userInfo } from "@/types/app"
// import { getUsetInfo } from "@/api/user-app";
interface app {
    updateTime: string
    createTime: string
    nickName: string
    account: string
    phone: string
    sex: string
    uuid: string
    address: string
    auth: number
    picture: string
    isAdmin: number
    points: number
    token: string
}
const appStore = defineStore({
    id: "app",
    state: (): any => ({
        token: "",
        info: {
            account: "",
            address: "",
            auth: 0,
            nickName: "",
            phone: "",
            sex: "",
            updateTime: "",
            uuid: "",
            createTime: "",
            picture: "",
            isAdmin: 0,
            points: 0
        }
    }),
    actions: {
        setToken(token: string) {
            this.token = token
        },
        setUserIinfo(info: app) {
            this.info = info
        }
    },
    getters: {
        getToken() {
          const s1 = getStorage("token");
          const token = s1 ? s1 : this.token
            return token
        },
        getUserInfo():app {
            return this.info
        },
    }
})
export function useAppStoreWithOut() {
    return appStore(store);
}
